<template>
  <div class="box bg-box">
    <t-button shape="square" variant="outline" @click="ticketStore.get" style="float: right">
      <template #icon>
        <t-icon name="refresh" />
      </template>
    </t-button>
    <t-form layout="inline" style="margin-bottom: 20px">
      <t-form-item label-width="0">
        <t-select v-model="ticketStore.where.key" style="width: 200px; margin-right: 10px">
          <t-option value="number" :label="plugin.t('ticket.number')" />
        </t-select>
        <t-input v-model="ticketStore.where.value">
          <template #prefix-icon>
            <t-icon name="search" />
          </template>
        </t-input>
      </t-form-item>
      <t-form-item label-width="0">
        <t-button theme="default" @click="ticketStore.reset(1)">{{ $t('common.search') }}</t-button>
      </t-form-item>
    </t-form>
    <Table @view="onView" />
    <PdfView ref="pdf" />
  </div>
</template>
<script setup>
  import { ref } from 'vue'
  import index from '../../index'
  import ticketStore from '../../store/ticket'
  import Table from './table.vue'
  import PdfView from '../../components/pdfview.vue'

  const plugin = index.plugin

  const pdf = ref()
  const onView = data => {
    pdf.value.open(data)
  }

</script>